<?php 
// 后台登录验证
$cookie = input('cookie');
if (isset($cookie["admin_token"])) {
    // 解码管理员 Token
    $token = authcode($cookie['admin_token'], 'DECODE', $conf['KEY']);
    list($user, $sid) = explode("\t", $token);
    $session = md5($conf['admin_user'] . $conf['admin_pass'] . $password_hash);
    
    // 检查管理员登录状态
    if ($session == $sid) {
        $islogin_admin = 1;
    } else {
        $islogin_admin = -1;
    }
}

// 用户登录验证
if (isset($cookie["user_token"])) {
    // 解码用户 Token
    $token = aes256auth(daddslashes($cookie['user_token']), "user_token", 'DECODE');
    list($user, $sid, $expiretime) = explode("\t", $token);
    
    // 查询用户信息
    $sql = "SELECT * FROM pay_user WHERE user=:user LIMIT 1";
    $params = ['user' => $user];
    $userrow = safeSqlQuery($sql, $params)['result'][0];
    
    // 初始化用户登录状态为未登录
    $islogin_user = -1;
    
    // 检查用户登录状态
    if ($userrow && md5($userrow['pid'].$userrow['key'].$password_hash) == $sid && $expiretime > time()) {
        $user_pid = $userrow['pid'];
        $islogin_user = 1;
    }
}





?>